package cn.gov.msa.service.impl;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import cn.gov.msa.dao.SuperviseMapper;
import cn.gov.msa.model.SupervisioRule;
import cn.gov.msa.pagehelper.CustomPageHelper;
import cn.gov.msa.service.SuperviseService;

public class SuperviseServiceImpl implements SuperviseService {
	
	@Autowired
	private SuperviseMapper superviseMapper;
	
	@Override
	public List<Map> limitList(int pageNum,int pageSize, Map map)throws Exception {
		String[] queryParam = new String[2];
		queryParam[0] = "cn.gov.msa.pagehelper.CustomOracleParse";
		queryParam[1] = "fnc_getorgnamebyorg(orgcode) orgname";
		
		CustomPageHelper.startPage(pageNum, pageSize,queryParam); // 核心分页代码 
		return superviseMapper.limitList(map);
	}

	@Override
	public List<Map> complaintList(int pageNum,int pageSize,Map map)throws Exception {
		CustomPageHelper.startPage(pageNum, pageSize); // 核心分页代码 
		return superviseMapper.complaintList(map);
	}

	@Override
	public List<SupervisioRule> ruleList(int pageNum,int pageSize,Map rule)throws Exception {
		CustomPageHelper.startPage(pageNum, pageSize); // 核心分页代码 
		return superviseMapper.ruleList(rule);
	}

	@Override
	public int delete(String ruleId) throws Exception {
		return superviseMapper.deleteBySuperviseRule(ruleId); 
	}

	@Override
	public boolean update(SupervisioRule rule) throws Exception {
		int i = superviseMapper.update(rule);
		if(i>0) {
			return true;
		}else {
			return false;
		}
	}

	@Override
	public SupervisioRule selectByRuleId(String ruleId) throws Exception {
		 
		return superviseMapper.selectByRuleId(ruleId);
	}

	@Override
	public boolean save(SupervisioRule rule) throws Exception {
		 int i = superviseMapper.save(rule);
		 if(i>0) {
			 return true;
		 }else {
			 return false;
		 }
	}

	@Override
	public List<Map> complaintDetail(int pageNum, int pageSize, Map map) throws Exception {
		String[] queryParam = new String[3];
		queryParam[0] = "cn.gov.msa.pagehelper.CustomOracleParse";
		queryParam[1] = "fnc_getorgnamebyorg(orgcode) orgname";
		queryParam[2] = "fnc_getdictnamebycode('DM_XKXMLX', itemtypecode) itemtypecodename";
		CustomPageHelper.startPage(pageNum, pageSize,queryParam); // 核心分页代码 
		return superviseMapper.complaintDetail(map);
	}

}
